#ifndef _STRAWGUI_TEXT_RECT_STRING_H_
#define _STRAWGUI_TEXT_RECT_STRING_H_

#include "sMath.h"
#include "sCRText.h"
#include "sComponentRectInstance.h"
#include <deque>

namespace sgui
{
namespace inst
{
	struct sTextSubString
	{
		std::wstring							m_content;
		math::sRectf							m_rect;
	};

	class sTextString
	{
	private:
		std::wstring							m_content;
		math::sRectf							m_rect;
		const res::EHorisontalFontAlign&		m_containerAlign;
		const inst::sComponentRectInstance&		m_container;
		const preset::sFontPreset*				m_preset;
		std::deque<sTextSubString>				m_subStrings;
    private:
        u32 getStringChar(const std::wstring& str, s32 position) const;
	public:
		sTextString(const inst::sComponentRectInstance& container, const std::wstring& content);

		const std::wstring& getContent() const;
		void setContent(const std::wstring& content);

		const math::sRectf& getRect() const;
		math::sRectf& getRect();

        u32 getCharAt(const math::sPointf& point) const;
        void getCursorPosition(u32 char_, math::sPointf& res_pos, f32& res_height) const;

		void draw(engine::sDrawStack& drawStack) const;
		void update(const preset::sFontPreset *preset);
	};
};
};

#endif